package org.rpgmapper.adapter;

import org.rpgmapper.bo.Environment;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;


public class MapAdapter extends BaseAdapter {
	private final int[] mapIcons = Environment.ids(); 
	private Context context;
	public MapAdapter(Context context) {
		this.context = context;
	}
	public int getCount() {
		return mapIcons.length;
	}
	public Object getItem(int position) {
		return mapIcons[position];
	}
	public long getItemId(int position) {
		return position;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(context);
		} else {
			imageView = (ImageView)convertView;
		}
		imageView.setImageResource(mapIcons[position]);
		imageView.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				//Toast.makeText(Main.this, "on change de fond", Toast.LENGTH_SHORT).show();
			}
		});
		return imageView;
	}
}
